package com.yisu.expressway.api.web.interceptor;


import javax.servlet.*;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by nichole on 2017/1/2.
 */
public class ResponseHeaderFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletResponse httpServletResponse = (HttpServletResponse) response;
        httpServletResponse.setHeader("Access-Control-Allow-Origin", "*");
        httpServletResponse.setHeader("Access-Control-Allow-Headers", "Content-Type,X-Client-Agent,X-APIVersion,X-Client-ID,X-User-ID,X-Long-Token");

//        response.setHeader("Access-Control-Allow-Methods", "POST,GET");

        chain.doFilter(request, httpServletResponse);
    }

    @Override
    public void destroy() {

    }
}
